Skip to content

Conversation

NoahStapp
Copy link
Contributor

No description provided.

sleepyStick
sleepyStick previously approved these changes Apr 2, 2025
self._closed = False
self._loop: Optional[asyncio.AbstractEventLoop] = None
if not _IS_SYNC:
# Check if the client was created within a running event loop.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this part since it's overly restrictive. We should only bind the loop on the first operation.

if self._loop is None:
self._loop = asyncio.get_running_loop()
else:
if self._loop != asyncio.get_running_loop():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we could make this an elif

if self._loop is None:
self._loop = asyncio.get_running_loop()
elif self._loop != asyncio.get_running_loop():
raise RuntimeError("Cannot use AsyncMongoClient in different event loop")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any docs we can point to in this error message? Or can we make it a bit more explanatory?

@NoahStapp NoahStapp merged commit 708ce16 into mongodb:master Apr 4, 2025
34 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants